const joi = require('joi')

// 定义 id, nickname, emial 的验证规则
const id = joi.number().integer().min(1).required()
const nickname = joi.string().required()
const email = joi.string().email().required()
const password = joi.string().pattern(/^[\S]{6,12}$/).required()
// dataUri() 指的是如下格式的字符串数据：
// 
const avatar = joi.string().dataUri().required()


exports.update_userinfo_schema = {
	body: {
		id,
    	nickname,
    	email,
	}
}

exports.update_pwd_schema = {
	body: {
		oldPwd: password,
		newPwd: joi.not(joi.ref('oldPwd')).concat(password)
	}
}

// 验证规则对象 - 更新头像
exports.update_avatar_schema = {
  body: {
    avatar,
  },
}